'use strict'
module.exports = async (c , next) => { // token验证中间件
    let token = c.headers.authorization;

    if (!token) {
        return c.status(400).send("Token Is Null!");
    }
    
    let r = c.service.usertok.verify(token);

    if (!r.ok) {
        return c.status(403).send(r.errcode);
    }

    c.box.user = r.data;
    
    await next();
}